package com.ruoyi.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistic.domain.WDayExitWarehouseStat;
import com.ruoyi.statistic.service.IWDayExitWarehouseStatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日出库量Controller
 * 
 * @author wzy
 * @date 2024-09-01 17:13:01
 */
@RestController
@RequestMapping("/statistic/dayexit")
public class WDayExitWarehouseStatController extends BaseController
{
    @Autowired
    private IWDayExitWarehouseStatService wDayExitWarehouseStatService;

    /**
     * 查询日出库量列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayexit:list')")
    @GetMapping("/list")
    public TableDataInfo list(WDayExitWarehouseStat wDayExitWarehouseStat)
    {
        startPage();
        List<WDayExitWarehouseStat> list = wDayExitWarehouseStatService.selectWDayExitWarehouseStatList(wDayExitWarehouseStat);
        return getDataTable(list);
    }

    /**
     * 导出日出库量列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayexit:export')")
    @Log(title = "日出库量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WDayExitWarehouseStat wDayExitWarehouseStat)
    {
        List<WDayExitWarehouseStat> list = wDayExitWarehouseStatService.selectWDayExitWarehouseStatList(wDayExitWarehouseStat);
        ExcelUtil<WDayExitWarehouseStat> util = new ExcelUtil<WDayExitWarehouseStat>(WDayExitWarehouseStat.class);
        util.exportExcel(response, list, "日出库量数据");
    }

    /**
     * 获取日出库量详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayexit:query')")
    @GetMapping(value = "/{dayExitStatisticId}")
    public AjaxResult getInfo(@PathVariable("dayExitStatisticId") Long dayExitStatisticId)
    {
        return success(wDayExitWarehouseStatService.selectWDayExitWarehouseStatByDayExitStatisticId(dayExitStatisticId));
    }

    /**
     * 新增日出库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayexit:add')")
    @Log(title = "日出库量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WDayExitWarehouseStat wDayExitWarehouseStat)
    {
        wDayExitWarehouseStat.setCreateBy(getNickName());
        return toAjax(wDayExitWarehouseStatService.insertWDayExitWarehouseStat(wDayExitWarehouseStat));
    }

    /**
     * 修改日出库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayexit:edit')")
    @Log(title = "日出库量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WDayExitWarehouseStat wDayExitWarehouseStat)
    {
        wDayExitWarehouseStat.setUpdateBy(getNickName());
        return toAjax(wDayExitWarehouseStatService.updateWDayExitWarehouseStat(wDayExitWarehouseStat));
    }

    /**
     * 删除日出库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:dayexit:remove')")
    @Log(title = "日出库量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dayExitStatisticIds}")
    public AjaxResult remove(@PathVariable Long[] dayExitStatisticIds)
    {
        return toAjax(wDayExitWarehouseStatService.deleteWDayExitWarehouseStatByDayExitStatisticIds(dayExitStatisticIds));
    }
}
